﻿		<?php
				session_start();
				require_once('../config.php');
				include_once("../database/DataBase.php");
				include_once("function.php");

				$login_id = $_POST["login_id"];
				$pwd = md5($_POST["pwd"]);
				
				$database = New DataBase();
				$database->open_connection();
				$result = $database->getUserByLogin($login_id, $pwd);
				
				if(!is_null($result)){
					
					
					if (isset($_COOKIE["language"])){
						$_SESSION["language"] = $_COOKIE["language"];
					}
					else{
						$_SESSION["language"] = "1";
					}
					
					$_SESSION["login_id"] = $result["login_id"];
					$_SESSION["company_id"] = $result["cid"];
					$_SESSION["user_type"] = $result["type"];
					$_SESSION["num_of_lang"] = $result["num_of_lang"];
					$_SESSION["message"] = "";
					
					$database->LogAction($result["login_id"], "Login", "Login from IP: ".getIpAddress());
					
					echo "true";
				}
				else{
					echo "Login name or password error!";
				}
				
				$database->close_connection();
		?>
		